package com.mhc.haval.manager.impl;

import com.subaru.common.query.PageResult;
import com.mhc.haval.dal.model.WorkflowDO;
import com.mhc.haval.dal.query.WorkflowQuery;
import com.mhc.haval.dal.mapper.ext.WorkflowExtMapper;
import com.mhc.haval.manager.WorkflowManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Manager for Workflow.
 */

@Component
public class WorkflowManagerImpl implements WorkflowManager{

    
    @Autowired
    protected WorkflowExtMapper workflowExtMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(WorkflowQuery query){
        return workflowExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(WorkflowQuery query){
        return workflowExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(WorkflowDO record){
        return workflowExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(WorkflowDO record){
        return workflowExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<WorkflowDO> selectByQuery(WorkflowQuery query){
        return workflowExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<WorkflowDO> selectByQueryWithPage(WorkflowQuery query) {
        PageResult<WorkflowDO> result = new PageResult<WorkflowDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public WorkflowDO selectByPrimaryKey(Long id){
        return workflowExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( WorkflowDO record,  WorkflowQuery query){
        return workflowExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( WorkflowDO record,  WorkflowQuery query){

        return workflowExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(WorkflowDO record){
        return workflowExtMapper.updateByPrimaryKeySelective(record);
    }
}